#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(Calibrate *calibrateWin, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // pop-up Calibrate window on startup
    opencalibrate(calibrateWin);

    //connect(&timer, SIGNAL(timeout()), this, SLOT(timedOut()));
    //timer.start(50);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

 // pop-up Calibrate window on startup
void MainWindow::opencalibrate(Calibrate *calibrateWin)
{

    calibrateWin->show();
    calibrateWin->activateWindow();
    calibrateWin->raise();

}

void MainWindow::on_verticalSlider_valueChanged()
{
  // must have cpufreq installed
    // the command line below gets the current governor
    // cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    if(ui->verticalSlider->value() == 1)
    {
        system("cpufreq-set -g performance");

    }
    else if(ui->verticalSlider->value() == 0)
    {
        system("cpufreq-set -g powersave");
    }

}

void MainWindow::timedOut()
{
}
